// 替换url占位符
export function replacePlaceholder(url, obj) {
	let array = []
	array = url.match(/{(.*?)}/g).map((param) => param.substring(1, param.length - 1))
	// 使用正则表达式，循环替换占位符数据
	for (let i = 0; i < array.length; i++) {
		if (obj[array[i]]) {
			url = url.replace(new RegExp('\\{' + array[i] + '\\}', 'g'), obj[array[i]])
		}
	}
	return url
}

// 数组去重
export function arrayRemoveSame(arr, field) {
  const newArr = []
  arr.forEach(element => {
    let bin = false
    for (let i = 0; i < newArr.length; i++) {
      if (newArr[i][field] === element[field]) {
        bin = true
        break
      }
    }
    if (!bin) {
      newArr.push(element)
    }
  })

  return newArr
}